<template>
	<view class="container">
		<view class="header align-center justify-between plr14 ft16">
			<view :class="act==0?'on flex1':'flex1' " @click="act=0">
				详情
			</view>
			<view :class="act==1?'on flex1 middle':'flex1 middle' " @click="act=1">
				目录
			</view>
			<view :class="act==2?'on flex1':'flex1' " @click="act=2">
				讨论
			</view>
		</view>
		<view style="height: 110rpx;">

		</view>

		<view class="mt5" v-if="act==0">
			<view class="bgWhite pb15 boxshadow20">
				<view class="flex align-center  coursedata ">
					<image :src="$domain.ossapi+detail.image" mode=""></image>
					<view class="flex1 flex-col justify-between " style="height: 236rpx">
						<view class="clamp2 title">
							{{detail.title}}
						</view>
						<text>学时：{{detail.xueshi}}</text>
						<view class="flex1">

						</view>
						<view class="price">
							￥{{detail.price}}
						</view>
					</view>
				</view>


				<view class="align-center justify-between menudata">
					班级编号: <text> {{detail.class}}</text>
				</view>
				<view class="align-center justify-between menudata">
					举办单位: <text>  {{detail.danwei}}</text>
				</view>
				<view class="align-center justify-between menudata">
					报名开始: <text>  {{detail.starttime}}</text>
				</view>
				<view class="align-center justify-between menudata " style="margin-bottom: 0;">
					报名截止: <text>  {{detail.endtime}}</text>
				</view>
			</view>
			<view class="mt15 mlr15 bgWhite radius10 boxshadow20 pb15">
				<view class="moduletitle  align-center justify-start plr15">
					<text></text>
					<view class="ft16 ml10">
						课程简介
					</view>

				</view>
				<view class="maininfo justify-center ptb15 ">
					<image :src="$domain.ossapi+ detail.detail_image" mode="widthFix"></image>
				</view>
			</view>
		</view>

		<view class="bgWhite boxshadow20 mt15 ptb15 plr15" v-if="act==1">
			<uv-collapse ref="collapse" accordion @open="open">
				<uv-collapse-item  v-for="(i,n) in muluList" :key="n" :name="n">
					<view slot="title" class="uv-page__item__title__slot-title slottitle align-center ">
						<image class="mr5" src="../../static/images/list_img19.png" mode="widthFix"></image>{{i.title}}
					</view>
					<view class="uv-collapse-content" style="height: auto!important;" v-if="i.child&&i.child.length">
						<view class="contentbox  align-center justify-between" v-for="(item,index) in i.child" :key="n" @click="ToMain(item)">
							<view class="contentTitle">
										课程{{index+1}}
							</view>			
							<view class="contentdesc flex1 clamp">{{item.title}}</view>
						</view>
					
					</view>
				</uv-collapse-item>
				
			</uv-collapse>
		</view>
		<view class="" style="height: 200rpx;">
		</view>
		<view v-if="!isLogin" class="submit bgWhite boxshadow20">
			<view class="logbtn" @click="learn">
			登录学习
			</view>
		</view>

	</view>
</template>

<script>
	let app = getApp();
	export default {
		components: {

		},
		data() {
			return {
				act: 0,
				id:"",
				detail:{},
				isLogin:uni.getStorageSync('logintoken'),
				muluList:[]
			}
		},
		onLoad(opt) {
			
			if(opt.id){
				this.id =opt.id
				this.getDetail()
			}

		},
		mounted() {



			// 使用函数生成一个正弦波形


		},

		methods: {
			learn(){
					
				if(this.isLogin){
					uni.navigateTo({
						url:'/pages/confirm/index?id='+this.id
					})
				}else{
					uni.reLaunch({
						url:'/pages/login/login'
					})
				}
			},
			getDetail(){
				this.$api.getDetailInfo({id:this.id}).then(res=>{
					console.log(res)
					this.detail =res.data
				})
				this.$api.getMulu({info_id:this.id}).then(res=>{
					console.log(res)
					this.muluList =res.data
				})
			},
			open(e){
				console.log(e)
				// this.$api.getContent({id:this.muluList[e].id}).then(res=>{
					
				// 	this.muluList[e]={
				// 		...this.muluList[e],
				// 		...{
				// 			classlist:res.data
				// 		}
				// 	}	
				// 		console.log(this.muluList)
					
				// })
			},
			ToMain(item){
				if(!this.detail.isBm)return this.$utils.msg('请先报名后再进行学习')
				uni.navigateTo({
					url:'/pages/video/index?id='+item.id 
				})
			}
			
			
		}





	}
</script>
<style scoped lang="scss">
	page {
		color: #343434;
	}

	.header {
		width: 100%;
		height: 110rpx;
		background-color: #fff;

		box-sizing: border-box;
		color: #969696;
		position: fixed;
		top: 88rpx;
		left: 0;
		z-index: 999;
		display: flex;

		view {
			text-align: center;
			font-size: 28rpx;
			height: 100%;
			display: flex;
			align-items: center;
			justify-content: center;
		}

		.on {
			color: #000;
			position: relative;
		}

		.on::after {
			content: "";
			width: 20rpx;
			height: 4rpx;

			background: #0082DB;
			position: absolute;
			bottom: 0;
			left: 0;
			right: 0;
			margin: auto;

		}

		.middle {
			position: relative;
		}

		.middle::after {
			content: "";
			width: 2rpx;
			height: 30rpx;
			background: #E0E0E0;
			position: absolute;
			top: 0;
			bottom: 0;
			margin: auto;
			right: 0;
		}

		.middle::before {
			content: "";
			width: 2rpx;
			height: 30rpx;
			background: #E0E0E0;
			position: absolute;
			top: 0;
			bottom: 0;
			margin: auto;
			left: 0;
		}
	}



	.tag {
		background-color: rgb(255, 219, 109);
		color: #fff;
		font-size: 26rpx;
		padding: 4rpx 8rpx;
		border-radius: 10rpx;
		margin-right: 10rpx;
	}

	.coursedata {
		padding: 20rpx;
		color: #969696;
		font-size: 24rpx;

		image {
			width: 300rpx;
			height: 236rpx;
			border-radius: 15rpx;
			margin-right: 20rpx;
		}

		.title {
			font-size: 33rpx;
			color: #000;
			margin-bottom: 10rpx;
		}

		.price {
			font-weight: bold;
			color: #1FACFF;
			font-size: 42rpx;
		}
	}

	.menudata {
		margin: 20rpx;
		height: 72rpx;
		border: 1px solid #cad9fe;
		font-size: 28rpx;
		border-radius: 10rpx;
		padding: 0 20rpx;
	}

	.moduletitle {
		height: 116rpx;

		text {

			width: 6rpx;
			height: 18rpx;
			background: #0082DB;
			border-radius: .5rem;
			display: block;
		}
	}

	.maininfo {
		border-top: 2rpx solid #E0E0E0;


	}

	.submit {
		width: 700rpx;
		padding: 20rpx;
		height: 140rpx;
		border-radius: 20rpx;
		position: fixed;
		left: 0;
		right: 0;
		margin: auto;
		bottom: 40rpx;
	}

	.logbtn {
		background: linear-gradient(180deg, #98D5FF 0%, #0082DB 100%);
		border-radius: 20rpx;
		width: 100%;
		height: 100rpx;
		text-align: center;
		line-height: 100rpx;
		color: #fff;
	}
	.slottitle{
		font-size: 34rpx;
		color: #343434;
		image{
			width: 56rpx;
			height: 56rpx;
		}
	}
	.contentbox{
		border: 1px solid #E0E0E0;
		border-radius: 15rpx;
		padding:10rpx 20rpx;
		font-size: 24rpx;
	}
	.contentTitle{
		width: 147rpx;
		height: 84rpx;
		background-image: url('../../static/images/bg6.png');
		background-size: 100% 100%;
		margin-right: 20rpx;
		text-align: center;
		line-height: 84rpx;
		color: #0082DB;
	}
	
	// /deep/.uv-collapse-item__content{
	// 	height: auto!important;
	// }
</style>